POV-Ray : Newsgroups : povray.general : Need of a macro or a trick : Re: Need of a macro or a trick Server Time
1 Aug 2024 16:32:14 EDT (-0400)
  Re: Need of a macro or a trick  
From: "Jérôme M. Berger"
Date: 25 Jul 2005 17:19:24
Message: <42e5575c@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bancquart.sebastien wrote:
| #declare leaves=union {
|     object {leave} matrix <....>
|     object {leave} matrix <....>
|     object {leave} matrix <....>
| ...   ... about 24000 lines like that
| }
|
	If you have one line per object and nothing else in the file
(not even the "#decleare leaves=union {" and "}" lines, then the
following python code should do what you want:

############################################################
from random import shuffle

f = open ("file.inc", "r")
l = f.readlines()
f.close()
shuffle (l)
f = open ("one.inc", "w")
f.writelines (l[:len(l)/3])
f.close()
f = open ("two.inc", "w")
f.writelines (l[len(l)/3:(2*len(l))/3])
f.close()
f = open ("three.inc", "w")
f.writelines (l[(2*len(l))/3:])
f.close()
############################################################

	Note that if you have kept the first and last lines in the input
file, you can get rid of them by replacing line 4 by:
"l = f.readlines()[1:-1]"

		Jerome
- --
******************************
*      Jerome M. Berger      *
*  mailto:jeb### [at] freefr   *
*  http://jeberger.free.fr/  *
******************************
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFC5VdbqIYJdJhyixIRAmkXAJ4la65rHfh0j5LWGQOE6HxZG28y3wCfVZIU
DuAnJWsIWX1PBg6GQwJQ3AU=
=SEn/
-----END PGP SIGNATURE-----


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.